﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using PTCapture.Support;

namespace PTCapture.Support.Angles
{
    /// <summary>
    /// A 3 point angle.
    /// </summary>
    public class UserAngle
    {
        #region Fields

        /// <summary>
        /// End point
        /// </summary>
        public Point? A =  null;

        /// <summary>
        /// Midpoint
        /// </summary>
        public Point? B = null;

        /// <summary>
        /// End point
        /// </summary>
        public Point? C = null;

        /// <summary>
        /// Color to draw it
        /// </summary>
        public Color DrawColor;

        /// <summary>
        /// True is acute, false is obtuse
        /// </summary>
        public bool Acute;

        /// <summary>
        /// Whether to draw this angle
        /// </summary>
        public bool Visible;

        /// <summary>
        /// Calculate the angle using B as the midpoint.
        /// -1 if not able to.
        /// </summary>
        public double Angle
        {
            get
            {
                if (A.HasValue &&
                    B.HasValue &&
                    C.HasValue)
                {

                    return MathFunctions.GetAngle(A.Value, B.Value, C.Value);
                }
                else
                {
                    return -1;
                }
            }
        }

        #endregion

        #region Initialization

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="drawColor"></param>
        /// <param name="acute"></param>
        public UserAngle(Color drawColor, bool acute)
        {
            DrawColor = drawColor;
            Acute = acute;

            Visible = true;
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="c"></param>
        /// <param name="drawColor"></param>
        /// <param name="acute"></param>
        public UserAngle(Point? a, Point? b, Point? c, Color drawColor, bool acute)
        {
            A = a;
            B = b;
            c = C;

            DrawColor = drawColor;

            Acute = acute;

            Visible = true;
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="angle"></param>
        public UserAngle(UserAngle angle)
        {
            A = angle.A;
            B = angle.B;
            C = angle.C;

            DrawColor = angle.DrawColor;

            Acute = angle.Acute;

            Visible = angle.Visible;
        }

        #endregion
    }
}
